package com.wxCompany.robot;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.aliyun.openservices.shade.com.alibaba.fastjson.JSON;

public class WxCompanyRobotMessageTest {
    public static void main(String[] args) {
        String url ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9660791c-3c8d-4451-944c-65993ff31feb";

        String text = "{\"success\":null,\"data\":{\"success\":false,\"code\":403,\"message\":\"传感器未安装在轮位上\"},\"message\":\"传感器未安装在轮位上\",\"status\":400,\"code\":\"403\"}";
        String path = "https://open-p.zhilunkeji.com/open/api/wheels/opt/uninstallSensorNo?accessKey=ade0ccb442c945fb939a2f82193f6cdf&timestamp=1725499947&sign=36b006f3d36cf4dbba3526f36c76e270";
        String req = "{\"sensorNo\":\"22149932\",\"operator\":\"黄超凡\"}";

        // 构建消息内容
        String content = WxCompanyRobotMessage.buildContent(text, path, req);

        // 创建消息对象
        WxCompanyRobotMessage param = new WxCompanyRobotMessage("markdown", content);

        // 打印消息的 JSON 格式
       // System.out.println(param.toString());

        HttpRequest request = HttpUtil.createPost(url).body(JSON.toJSONString(param));



        System.out.println("body: " );
        System.out.println(JSON.toJSONString(param));
        // 执行请求并获取响应
        HttpResponse response = request.execute();

        // 获取响应结果
        String result = response.body();
        System.out.println("Response: " );
        System.out.println(result);
    }
}
